<div class="card-body">
<div class="card-btns mb-2-5">
  <button class="btn btn-info" type="button" data-bs-toggle="modal" data-bs-target="#modal-bgtf" onclick="bgtf()"><i class="mdi mdi-content-save"></i> 报告退费</button>
  <button class="btn btn-info" type="button" data-bs-toggle="modal" data-bs-target="#modal-ywjd" onclick="ywjd()"><i class="mdi mdi-content-save"></i> 业务结单</button>
  <button class="btn btn-info" type="button" data-bs-toggle="modal" data-bs-target="#modal-hzdj" onclick="hzdj()"><i class="mdi mdi-content-save"></i> 坏账登记</button>
</div>
<div class="table-responsive">
  <table class="table table-bordered">
      <tr>
        <th>总应收</th>
        <td>{:$statistics['receivable']}</td>
        <th>已收</th>
        <td>{:$statistics['yishou']}</td>
        <th>未收款</th>
        <td>{:$statistics['weishou']}</td>
      </tr>
      <tr>
        <th>工本费</th>
        <td>{:$statistics['gongben']}</td>
        <th>总应退</th>
        <td>{:$statistics['yingtui']}</td>
        <th>已(实)退</th>
        <td>{:$statistics['yitui']}</td>
      </tr>
      <tr>
        <th>收费状态</th>
        <td>{:$statistics['status']}</td>
      </tr>
 
  </table>
</div>
</div>

<!--业务结单-->
<div class="modal fade bs-example-modal-lg in" data-bs-backdrop="static" tabindex="-1" id="modal-ywjd">
  <div class="modal-dialog modal-xl modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h6 class="modal-title" id="exampleModalLiveLabel">业务结单</h6>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body" style="padding-top:0.5rem;">
        <form action="" method="post" id="ywjd_content">
          <input type="hidden" name="order_id" value="{:$order['id']}" />
          
          <div class="row mb-3">
              <?php $field = 'is_free'; $vo = ['name'=>'免单','type'=>'select1','params'=>$InvoiceRecordModel->getCommonIsList()]; ?>
              <div class="col-md-4">
                {include file="html/fields/select1" /}
              </div>

              <?php $field = 'commission_ratio'; $vo = ['name'=>'佣金比例','type'=>'text']; ?>
              <div class="col-md-4">
                {include file="html/fields/text" /}
              </div>

              <?php $field = 'commission_amount'; $vo = ['name'=>'佣金金额','type'=>'text']; ?>
              <div class="col-md-4">
                {include file="html/fields/text" /}
              </div>
          </div>

          <div class="row mb-3">
              <?php $field = 'commission_time'; $vo = ['name'=>'佣金结算日期','type'=>'date','value'=>emptyDef($data['commission_time'],date('Y-m-d'))]; ?>
              <div class="col-md-4">
                {include file="html/fields/date" /}
              </div>

              <?php $field = 'jd_time'; $vo = ['name'=>'结单日期','type'=>'date','value'=>emptyDef($data['jd_time'],date('Y-m-d'))]; ?>
              <div class="col-md-4">
                {include file="html/fields/date" /}
              </div>

              
          </div>


          <div class="row mb-3">
              <?php $field = 'jd_remark'; $vo = ['name'=>'备注','type'=>'textarea']; ?>
              <div class="col-md-8">
                {include file="html/fields/textarea" /}
              </div>
          </div>


        </form>  
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary submit_jd_btn" data-bs-dismiss="modal">保存</button>
      </div>
    </div>
  </div>
</div>

<!--坏账登记-->
<div class="modal fade bs-example-modal-lg in" data-bs-backdrop="static" tabindex="-1" id="modal-hzdj">
  <div class="modal-dialog modal-xl modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h6 class="modal-title" id="exampleModalLiveLabel">坏账登记</h6>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body" style="padding-top:0.5rem;">
        <form action="" method="post" id="hzdj_content">
          <input type="hidden" name="order_id" value="{:$order['id']}" />
          
          <div class="row mb-3">

              <?php $field = 'hz_amount'; $vo = ['name'=>'坏账金额','type'=>'text']; ?>
              <div class="col-md-4">
                {include file="html/fields/text" /}
              </div>
          </div>



          <div class="row mb-3">
              <?php $field = 'hz_remark'; $vo = ['name'=>'备注','type'=>'textarea']; ?>
              <div class="col-md-8">
                {include file="html/fields/textarea" /}
              </div>
          </div>


        </form>  
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary submit_hz_btn" data-bs-dismiss="modal">保存</button>
      </div>
    </div>
  </div>
</div>


<script type="text/javascript">
  
  $(".submit_jd_btn").on('click',function(){
    var params = $("#ywjd_content").serialize();
    $.ajax({
        url:'{:url("charge/ywjd")}',
        data:params,
        type:'post',
        dataType:'json',
        success:function(data){
          if (data.code == '2000') {
            cchUtil.message(data.msg);
          }else{
            cchUtil.message(data.msg,'danger');
          }
        }
    });
  });

  $(".submit_hz_btn").on('click',function(){
    var params = $("#hzdj_content").serialize();
    $.ajax({
        url:'{:url("charge/hzdj")}',
        data:params,
        type:'post',
        dataType:'json',
        success:function(data){
          if (data.code == '2000') {
            cchUtil.message(data.msg);
          }else{
            cchUtil.message(data.msg,'danger');
          }
        }
    });
  });

  
</script>